package com.okRPC.serialization;

import lombok.Getter;

/**
 * Description: This is a sample class.
 * Author: Simon
 * Date: 2023/10/10
 */
public enum SerializationTypeEnum {
    HESSIAN((byte) 0),
    JSON((byte) 1);

    @Getter
    private final byte type;

    SerializationTypeEnum(byte type) {
        this.type = type;
    }

    public static SerializationTypeEnum parseByName(String typeName) {
        for (SerializationTypeEnum typeEnum : SerializationTypeEnum.values()) {
            if (typeEnum.name().equalsIgnoreCase(typeName)) {
                return typeEnum;
            }
        }
        //default
        return HESSIAN;
    }

    public static SerializationTypeEnum parseByType(byte type) {
        for(SerializationTypeEnum typeEnum: SerializationTypeEnum.values()) {
            if(typeEnum.getType()==type){
                return typeEnum;
            }
        }
        return HESSIAN;
    }
}
